package com.wwj.controller.admin;


import com.wwj.common.result.PageResult;
import com.wwj.common.result.Result;
import com.wwj.pojo.dto.AdminOrderDTO;
import com.wwj.pojo.dto.OrderDTO;
import com.wwj.pojo.dto.OrderPageQueryDTO;
import com.wwj.pojo.dto.SetmealDTO;
import com.wwj.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController("adminOrderController")
@RequestMapping("/admin/order")
@Slf4j
@Api(tags="体检预约相关接口")
public class OrderController {

    @Resource
    private OrderService orderService;


    @GetMapping("/page")
    @ApiOperation(value = "分页查询")
    public Result<PageResult> pageQuery(OrderPageQueryDTO orderPageQueryDTO){
        PageResult pageResult=orderService.pageQuery(orderPageQueryDTO);
        return Result.success(pageResult);
    }

    @PutMapping
    @ApiOperation(value = "修改预约单")
    @CacheEvict(cacheNames = "OrderCache",allEntries = true)
    public Result update(@RequestBody AdminOrderDTO adminOrderDTO){
        orderService.update(adminOrderDTO);
        return Result.success();
    }

    //删除体检项目
    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除体检预约单")
    @CacheEvict(cacheNames = "OrderCache",allEntries = true)
    public Result deleteOrder(@PathVariable Long id){
        orderService.deleteOrder(id);
        return Result.success();
    }
}
